home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / AExamples / Sample.r < prev    next >
Encoding:
Text File  |  1998-12-03  |  6.1 KB  |  282 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989, 1998 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89    MPW 3.1
  18. #                1.03                02/90    MPW 3.2
  19. #                1.04                06/98    Universal Interfaces 3.1
  20. #
  21. #    Components:
  22. #                Sample.a            Feb.  1, 1990
  23. #                Sample.inc1.a        Feb.  1, 1990
  24. #                SampleMisc.a        Feb.  1, 1990
  25. #                Sample.r            Feb.  1, 1990
  26. #                Sample.h            Feb.  1, 1990
  27. #                Sample.make            Feb.  1, 1990
  28. #
  29. #    Sample is an example application that demonstrates how to
  30. #    initialize the commonly used toolbox managers, operate 
  31. #    successfully under MultiFinder, handle desk accessories, 
  32. #    and create, grow, and zoom windows.
  33. #
  34. #    It does not by any means demonstrate all the techniques 
  35. #    you need for a large application. In particular, Sample 
  36. #    does not cover exception handling, multiple windows/documents, 
  37. #    sophisticated memory management, printing, or undo. All of 
  38. #    these are vital parts of a normal full-sized application.
  39. #
  40. #    This application is an example of the form of a Macintosh 
  41. #    application; it is NOT a template. It is NOT intended to be 
  42. #    used as a foundation for the next world-class, best-selling, 
  43. #    600K application. A stick figure drawing of the human body may 
  44. #    be a good example of the form for a painting, but that does not 
  45. #    mean it should be used as the basis for the next Mona Lisa.
  46. #
  47. #    We recommend that you review this program or TESample before 
  48. #    beginning a new application.
  49. ------------------------------------------------------------------------------*/
  50.  
  51.  
  52. #include "Types.r"
  53.  
  54. #include "Sample.h"
  55.  
  56.  
  57. /* this is a definition for a resource which contains only a rectangle */
  58.  
  59. type 'RECT' {
  60.     rect;
  61. };
  62.  
  63.  
  64. /* we use an MBAR resource to conveniently load all the menus */
  65.  
  66. resource 'MBAR' (rMenuBar, preload) {
  67.     { mApple, mFile, mEdit, mLight };    /* four menus */
  68. };
  69.  
  70.  
  71. resource 'MENU' (mApple, preload) {
  72.     mApple, textMenuProc,
  73.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  74.     enabled, apple,
  75.     {
  76.         "About Sample…",
  77.             noicon, nokey, nomark, plain;
  78.         "-",
  79.             noicon, nokey, nomark, plain
  80.     }
  81. };
  82.  
  83. resource 'MENU' (mFile, preload) {
  84.     mFile, textMenuProc,
  85.     MenuItem12,                /* enable Quit only, program enables others */
  86.     enabled, "File",
  87.     {
  88.         "New",
  89.             noicon, "N", nomark, plain;
  90.         "Open",
  91.             noicon, "O", nomark, plain;
  92.         "-",
  93.             noicon, nokey, nomark, plain;
  94.         "Close",
  95.             noicon, "W", nomark, plain;
  96.         "Save",
  97.             noicon, "S", nomark, plain;
  98.         "Save As…",
  99.             noicon, nokey, nomark, plain;
  100.         "Revert",
  101.             noicon, nokey, nomark, plain;
  102.         "-",
  103.             noicon, nokey, nomark, plain;
  104.         "Page Setup…",
  105.             noicon, nokey, nomark, plain;
  106.         "Print…",
  107.             noicon, nokey, nomark, plain;
  108.         "-",
  109.             noicon, nokey, nomark, plain;
  110.         "Quit",
  111.             noicon, "Q", nomark, plain
  112.     }
  113. };
  114.  
  115. resource 'MENU' (mEdit, preload) {
  116.     mEdit, textMenuProc,
  117.     NoItems,                /* disable everything, program does the enabling */
  118.     enabled, "Edit",
  119.      {
  120.         "Undo",
  121.             noicon, "Z", nomark, plain;
  122.         "-",
  123.             noicon, nokey, nomark, plain;
  124.         "Cut",
  125.             noicon, "X", nomark, plain;
  126.         "Copy",
  127.             noicon, "C", nomark, plain;
  128.         "Paste",
  129.             noicon, "V", nomark, plain;
  130.         "Clear",
  131.             noicon, nokey, nomark, plain
  132.     }
  133. };
  134.  
  135. resource 'MENU' (mLight, preload) {
  136.     mLight, textMenuProc,
  137.     NoItems,                /* disable everything, program does the enabling */
  138.     enabled, "Traffic",
  139.      {
  140.         "Red Light",
  141.             noicon, nokey, nomark, plain;
  142.         "Green Light",
  143.             noicon, nokey, nomark, plain
  144.     }
  145. };
  146.  
  147.  
  148. /* this ALRT and DITL are used as an About screen */
  149.  
  150. resource 'ALRT' (rAboutAlert, purgeable) {
  151.     {40, 20, 160, 290},
  152.     rAboutAlert,
  153.     { /* array: 4 elements */
  154.         /* [1] */
  155.         OK, visible, silent,
  156.         /* [2] */
  157.         OK, visible, silent,
  158.         /* [3] */
  159.         OK, visible, silent,
  160.         /* [4] */
  161.         OK, visible, silent
  162.     },
  163.     centerMainScreen
  164. };
  165.  
  166. resource 'DITL' (rAboutAlert, purgeable) {
  167.     { /* array DITLarray: 5 elements */
  168.         /* [1] */
  169.         {88, 180, 108, 260},
  170.         Button {
  171.             enabled,
  172.             "OK"
  173.         },
  174.         /* [2] */
  175.         {8, 8, 24, 214},
  176.         StaticText {
  177.             disabled,
  178.             "Simple Sample (Traffic Light)"
  179.         },
  180.         /* [3] */
  181.         {32, 8, 48, 237},
  182.         StaticText {
  183.             disabled,
  184.             "Copyright © 1989 Apple Computer"
  185.         },
  186.         /* [4] */
  187.         {56, 8, 72, 136},
  188.         StaticText {
  189.             disabled,
  190.             "Brought to you by:"
  191.         },
  192.         /* [5] */
  193.         {80, 24, 112, 167},
  194.         StaticText {
  195.             disabled,
  196.             "Macintosh Developer  Technical Support"
  197.         }
  198.     }
  199. };
  200.  
  201.  
  202. /* this ALRT and DITL are used as an error screen */
  203.  
  204. resource 'ALRT' (rUserAlert, purgeable) {
  205.     {40, 20, 120, 260},
  206.     rUserAlert,
  207.     { /* array: 4 elements */
  208.         /* [1] */
  209.         OK, visible, silent,
  210.         /* [2] */
  211.         OK, visible, silent,
  212.         /* [3] */
  213.         OK, visible, silent,
  214.         /* [4] */
  215.         OK, visible, silent
  216.     },
  217.     noAutoCenter
  218. };
  219.  
  220.  
  221. resource 'DITL' (rUserAlert, purgeable) {
  222.     { /* array DITLarray: 3 elements */
  223.         /* [1] */
  224.         {50, 150, 70, 230},
  225.         Button {
  226.             enabled,
  227.             "OK"
  228.         },
  229.         /* [2] */
  230.         {10, 60, 30, 230},
  231.         StaticText {
  232.             disabled,
  233.             "Sample - Error occurred!"
  234.         },
  235.         /* [3] */
  236.         {8, 8, 40, 40},
  237.         Icon {
  238.             disabled,
  239.             2
  240.         }
  241.     }
  242. };
  243.  
  244.  
  245. resource 'WIND' (rWindow, preload, purgeable) {
  246.     {60, 40, 290, 160},
  247.     noGrowDocProc, visible, noGoAway, 0x0, "Traffic", noAutoCenter
  248. };
  249.  
  250. resource 'RECT' (rStopRect, preload, purgeable) {
  251.     {10, 10, 110, 110}
  252. };
  253.  
  254. resource 'RECT' (rGoRect, preload, purgeable) {
  255.     {120, 10, 220, 110}
  256. };
  257.  
  258.  
  259. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  260.  
  261. resource 'SIZE' (-1) {
  262.     dontSaveScreen,
  263.     acceptSuspendResumeEvents,
  264.     enableOptionSwitch,
  265.     canBackground,                /* we can background; we don't currently, but our sleep value */
  266.                                 /* guarantees we don't hog the Mac while we are in the background */
  267.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  268.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  269.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  270.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  271.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  272.     reserved,
  273.     reserved,
  274.     reserved,
  275.     reserved,
  276.     reserved,
  277.     reserved,
  278.     reserved,
  279.     kPrefSize * 1024,
  280.     kMinSize * 1024    
  281. };
  282.